﻿<View:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="ExampleApp.Views.TilesBadgesAndToastsView"
    IsTabStop="false"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:ExampleApp.Views"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:View="using:StyleMVVM.View"
    View:ViewModel.Name="TilesBadgesAndToastsViewModel"
    mc:Ignorable="d">

 <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Style="{StaticResource LayoutRootStyle}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Back button and page title -->
        <Grid Grid.ColumnSpan="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Navigation.CanGoBack}" Style="{StaticResource BackButtonStyle}"/>
            <TextBlock x:Name="pageTitle" Grid.Column="1" Text="Tiles, Toasts, and Badges" Style="{StaticResource PageHeaderTextStyle}"/>
        </Grid>

        <TextBlock FontSize="14" Margin="20,5" Grid.Row="1" TextWrapping="Wrap">
            Part of what makes Windows Store Apps unique are the Tiles, Toastes, and Badges. 
            To help you provide a great user experience the ITileService, IBadgeService, and IToastService have been created.
            Below are some examples of how to update your tile and send toasts.
            Note: None of these updates work in the simulator.
        </TextBlock>
        <Grid Grid.Row="2" >
            <TextBlock HorizontalAlignment="Left"  TextWrapping="Wrap" Text="Tile Text:"
                       VerticalAlignment="Top" FontSize="14" Margin="22,25,0,0" />
            <TextBox HorizontalAlignment="Left" Margin="22,47,0,0" TextWrapping="Wrap" Text="{Binding TileText,Mode=TwoWay}" VerticalAlignment="Top" Width="188"/>
            <Button View:EventHandlers.Attach="Click => UpdateTileText()"
                Content="Update Tile" HorizontalAlignment="Left" Margin="231,47,0,0" VerticalAlignment="Top" Width="149">
            </Button>
            
            <TextBlock HorizontalAlignment="Left" Margin="22,105,0,0" TextWrapping="Wrap" Text="Badge:" FontSize="14" VerticalAlignment="Top"/>
            <ComboBox ItemsSource="{Binding Glyphs}" SelectedItem="{Binding SelectedGlyph,Mode=TwoWay}"
                HorizontalAlignment="Left" Margin="22,127,0,0" VerticalAlignment="Top" Width="188"/>
            <Button View:EventHandlers.Attach="Click => UpdateBadge()"
                    Command="{Binding UpdateBadgeCommand}" Content="Update Badge" HorizontalAlignment="Left" Margin="231,125,0,0" VerticalAlignment="Top" Width="149"/>
            
            <TextBlock HorizontalAlignment="Left" Margin="22,184,0,0" TextWrapping="Wrap" Text="Toast Text:" FontSize="14" VerticalAlignment="Top"/>
            <TextBox HorizontalAlignment="Left" Margin="22,206,0,0" TextWrapping="Wrap" Text="{Binding ToastText,Mode=TwoWay}" VerticalAlignment="Top" Width="188"/>
            <Button View:EventHandlers.Attach="Click => SendToast()"
                    Content="Send Toast" HorizontalAlignment="Left" Margin="231,206,0,0" VerticalAlignment="Top" Width="149"/>

        </Grid>
        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!-- The back button and title have different styles when snapped -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</View:LayoutAwarePage>
